<admintpl file="header"/>
</head>
<body class="need_breadcrumb_back">
	<div class="wrap js-check-wrap">
		{:sp_get_admin_breadcrumb()}
		<form action="{:U('Api/edit_post')}" method="post" class="form-horizontal js-ajax-forms" enctype="multipart/form-data">
			<input type="hidden" name="id" value="{$api.id}">
			<div class="row-fluid mtop20">
				<div class="span7">
					<fieldset class="width80p">
						<div class="control-group">
							<label class="control-label">请求类型</label>
							<div class="controls">
								<label class="radio inline">
								  <input type="radio" name="method" value="GET" <eq name="api.method" value="GET">checked</eq>>
								  GET
								</label>
								<label class="radio inline">
								  <input type="radio" name="method" value="POST" <eq name="api.method" value="POST">checked</eq>>
								  POST
								</label>
								<label class="radio inline">
								  <input type="radio" name="method" value="PUT" <eq name="api.method" value="PUT">checked</eq>>
								  PUT
								</label>
								<label class="radio inline">
								  <input type="radio" name="method" value="DELETE" <eq name="api.method" value="DELETE">checked</eq>>
								  DELETE
								</label>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">名称</label>
							<div class="controls">
								<input type="text" name="name" value="{$api.name}" required>
								<span class="form-required">*</span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">版本标志</label>
							<div class="controls">
								<input type="text" name="version" placeholder="请输入整数版本号, 例如1 、 2 、3等" value="{$api.version}" required>
								<span class="form-required">*</span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">API路径</label>
							<div class="controls">
								<input type="text" name="path" placeholder="请输入请求地址, 如: /rst/user/list" value="{$api.path}" required>
								<span class="form-required">*</span>
							</div>							
						</div>
						<div class="control-group">
							<label class="control-label">所属分组</label>
							<div class="controls">
								<select name="gid">
									<option value="0"></option>
									<foreach name="grouplist" key="k" item="name">
										<option value="{$k}" <eq name="k" value="$api.gid">selected</eq>>{$name}</option>
									</foreach>
								</select>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">是否需要登录</label>
							<div class="controls">
								<label class="radio inline">
								  <input type="radio" name="oauth" value="1" <eq name="api.oauth" value="1">checked</eq>>
								  是
								</label>
								<label class="radio inline">
								  <input type="radio" name="oauth" value="0" <eq name="api.oauth" value="0">checked</eq>>
								  否
								</label>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">接口描述</label>
							<div class="controls">
								<textarea rows="3" name="introduce">{$api.introduce}</textarea>
								<span class="form-required">*</span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">注意事项</label>
							<div class="controls">
								<input type="text" name="warning" value="{$api.warning}" required>
								<span class="form-required">*</span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">发布状态</label>
							<div class="controls">
								<label class="radio inline">
								  <input type="radio" name="status" value="1" <eq name="api.status" value="1">checked</eq>>
								  上线
								</label>
								<label class="radio inline">
								  <input type="radio" name="status" value="0" <eq name="api.status" value="0">checked</eq>>
								  下线
								</label>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">模拟数据</label>
							<div class="controls">
								<textarea rows="3" name="analog_data">{$api.analog_data}</textarea>
								<span class="form-required">接口未实现时返回</span>
							</div>
						</div>
					</fieldset>
				</div>
				<div class="span5"></div>
			</div>
			<div class="form-actions">
				<button class="btn btn-primary js-ajax-submit" type="submit"><i class="fa fa-save" aria-hidden="true"></i>{:L("SAVE")}</button>
				<a class="btn" href="{:U('Api/index')}"><i class="fa fa-reply" aria-hidden="true"></i>{:L('BACK')}</a>
			</div>
		</form>
	</div>
	<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
	<script type="text/javascript">
		$(function() {
			ajaxFormSubmitInit({
					'version' : {required : 1},
					'path': {required : 1},
					'introduce': {required: 1},
					'warning': {required: 1}
				}, {
					'version' : {required : '请输入版本号'},
					'path': {required : '请输入请求路径'},
					'introduce': {required: '请输入接口介绍'},
					'warning': {required: '请输入注意事项'}
				}, [{
	                	name : '继续编辑？',
		                callback : function() {
		                    reloadPage(window);
		                    return true;
		                },
		                focus : true
		            }, {
		                name : '返回列表',
		                callback : function() {
		                    location.href = "{:U('Api/index')}";
		                    return true;
		                }
		            }
	            ]
            );
		});
	</script>
</body>
</html>